package com.bl.student.dao.repository;
import com.bl.student.dao.model.TaskEntity;
import com.bl.student.dao.model.TaskEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TaskRepository extends JpaRepository<TaskEntity, String> {
    Page<TaskEntity> findByPartyaIdAndStatusOrderByCreateTimeDesc(String partyaid, String status,Pageable pageable );

    Page<TaskEntity> findByPartybIdAndStatusOrderByCreateTimeDesc(String partybid, String status,Pageable pageable );

    Page<TaskEntity> findByPartyaIdOrderByCreateTimeDesc(String partyaid,Pageable pageable );

    Page<TaskEntity> findByPartybIdOrderByCreateTimeDesc(String partybid,Pageable pageable );

    @Query(value = "select * from task where if(?1 !='',classc=?1,1=1) and if(?2 !='',classb=?2,1=1) and if(?3 !='',classa=?3,1=1) and if(?4 !='',online=?4,1=1) and if(?5 !='',sex=?5,1=1) and if(?6 !='',price=?6,1=1) and if(?7 !='',language=?7,1=1) and if(?8 !='',grade=?8,1=1) and if(?9 !='',college=?9,1=1) and if(?10 !='',type=?10,1=1) and if(?11 !='',star=?11,1=1) and if(?12 !='',location=?12,1=1)and if(?13 !='',time=?13,1=1)and if(?14 !='',count=?14,1=1) and if(?15 !='',role=?15,1=1) and if(?16 !='',chinese=?16,1=1) and if(?17 !='',env=?17,1=1) and if(?18 !='',t_sex=?18,1=1) and if(?19 !='',status=?19,1=1) and if(?20 !='',buy_type=?20,1=1) and if(?21 !='',run_type=?21,1=1) ORDER BY create_time DESC \n#pageable\n",
            countQuery ="select * from task where if(?1 !='',class3=?1,1=1) and if(?2 !='',class2=?2,1=1) and if(?3 !='',class1=?3,1=1) and if(?4 !='',online=?4,1=1) and if(?5 !='',sex=?5,1=1) and if(?6 !='',price=?6,1=1) and if(?7 !='',language=?7,1=1) and if(?8 !='',grade=?8,1=1) and if(?9 !='',college=?9,1=1) and if(?10 !='',type=?10,1=1) and if(?11 !='',star=?11,1=1) and if(?12 !='',location=?12,1=1)and if(?13 !='',time=?13,1=1)and if(?14 !='',count=?14,1=1) and if(?15 !='',role=?15,1=1) and if(?16 !='',chinese=?16,1=1) and if(?17 !='',env=?17,1=1) and if(?18 !='',t_sex=?18,1=1) and if(?19 !='',status=?19,1=1) and if(?20 !='',buy_type=?20,1=1) and if(?21 !='',run_type=?21,1=1)",
            nativeQuery = true)
    Page <TaskEntity>  findMultList(String classc, String classb, String classa, String online, String sex, String price, String language, String grade, String college, String type, String star, String location, String time, String count, String role, String chinese, String env, String t_sex, String status, String buyType, String runType, Pageable pageable);

    @Query(value = "select * from task where if(?1 !='',classc=?1,1=1) and if(?2 !='',classb=?2,1=1) and if(?3 !='',classa=?3,1=1) and if(?4 !='',online=?4,1=1) and if(?5 !='',sex=?5,1=1) and if(?6 !='',price=?6,1=1) and if(?7 !='',language=?7,1=1) and if(?8 !='',grade=?8,1=1) and if(?9 !='',college=?9,1=1) and if(?10 !='',type=?10,1=1) and if(?11 !='',star=?11,1=1) and if(?12 !='',location=?12,1=1)and if(?13 !='',time=?13,1=1)and if(?14 !='',count=?14,1=1) and if(?15 !='',role=?15,1=1) and if(?16 !='',chinese=?16,1=1) and if(?17 !='',env=?17,1=1) and if(?18 !='',t_sex=?18,1=1) and if(?19 !='',status=?19,1=1) and if(?20 !='',buy_type=?20,1=1) and if(?21 !='',run_type=?21,1=1) ORDER BY create_time",
            countQuery ="select * from task where if(?1 !='',class3=?1,1=1) and if(?2 !='',class2=?2,1=1) and if(?3 !='',class1=?3,1=1) and if(?4 !='',online=?4,1=1) and if(?5 !='',sex=?5,1=1) and if(?6 !='',price=?6,1=1) and if(?7 !='',language=?7,1=1) and if(?8 !='',grade=?8,1=1) and if(?9 !='',college=?9,1=1) and if(?10 !='',type=?10,1=1) and if(?11 !='',star=?11,1=1) and if(?12 !='',location=?12,1=1)and if(?13 !='',time=?13,1=1)and if(?14 !='',count=?14,1=1) and if(?15 !='',role=?15,1=1) and if(?16 !='',chinese=?16,1=1) and if(?17 !='',env=?17,1=1) and if(?18 !='',t_sex=?18,1=1) and if(?19 !='',status=?19,1=1) and if(?20 !='',buy_type=?20,1=1) and if(?21 !='',run_type=?21,1=1)",
            nativeQuery = true)
    List<TaskEntity> findMultListAll(String classc, String classb, String classa, String online, String sex, String price, String language, String grade, String college, String type, String star, String location, String time, String count, String role, String chinese, String env, String t_sex, String status, String buyType, String runType);

    List<TaskEntity> findByStatus(String status);
}
